package md8800;

import java.util.Calendar;

public class Time
{

	private final Calendar CALENDAR = Calendar.getInstance();
	private int _tag;
	private int _monat;
	private int _jahr;

	private int _minute;
	private int _stunde;
	private char[] _chartable;

	public String gibZeit()
	{
		String s = "";
		CALENDAR.getTime();
		_tag = CALENDAR.get(Calendar.DAY_OF_MONTH);
		_monat = CALENDAR.get(Calendar.MONTH) + 1;
		_jahr = CALENDAR.get(Calendar.YEAR);

		_minute = CALENDAR.get(Calendar.MINUTE);
		_stunde = CALENDAR.get(Calendar.HOUR_OF_DAY);

		// 17:34 24.12.2005
		// Minute Stunde Monat Tag Jahr Jahr // 45 17 12 24 20 10

		_tag = Integer.parseInt("" + _tag, 16);
		_monat = Integer.parseInt("" + _monat, 16);

		int jahr1 = Integer.valueOf(("" + _jahr).substring(0, 2));
		int jahr2 = Integer.valueOf(("" + _jahr).substring(2, 4));

		// System.out.println(jahr1 + " " + jahr2);
		jahr1 = Integer.parseInt("" + jahr1, 16);
		jahr2 = Integer.parseInt("" + jahr2, 16);

		_minute = Integer.parseInt("" + _minute, 16);
		_stunde = Integer.parseInt("" + _stunde, 16);

		_chartable = new char[6];
		_chartable[0] = (char) _minute;
		_chartable[1] = (char) _stunde;
		_chartable[2] = (char) _tag;
		_chartable[3] = (char) _monat;
		_chartable[4] = (char) jahr1;
		_chartable[5] = (char) jahr2;

		// s += "" + _minute + "," + _stunde + "," + _monat + "," + _tag + ","
		// + jahr1 + "," + jahr2;

		for (int i = 0; i < _chartable.length; i++)
		{
			s += _chartable[i];
		}
		return s;

	}

	public String toString()
	{
		return CALENDAR.getTime().toString();

	}

	public char[] gibChars()
	{
		return _chartable;
	}

}
